import 'package:flutter/material.dart';

class SettingBar extends StatelessWidget {
  String? leftText = "";
  String? rightText = "";
  Widget? leftIcon;
  Widget? rightIcon;
  double? leftTextSize;
  Color? leftTextColor;
  double? leftIconSpace;
  double? rightTextSize;

  Color? rightTextColor;
  double? rightIconSpace;
  double? paddingVertical;
  double? paddingHorizontal;
  Color? backgroupColor;
  bool? showDivider;
  GestureTapCallback? onTap;
  double? radio;
  bool? leftTextBold;
  bool? rightTextBold;

  SettingBar(
      {this.leftText,
      this.rightText,
      this.leftIcon,
      this.rightIcon,
      this.leftTextSize,
      this.leftTextColor,
      this.leftIconSpace,
      this.rightTextSize,
      this.rightTextColor,
      this.rightIconSpace,
      this.paddingVertical,
      this.paddingHorizontal,
      this.backgroupColor,
      this.showDivider,
      this.onTap,
      this.radio,
      this.leftTextBold,
      this.rightTextBold
      });

  double leftTextSizeDefault = 14;
  Color leftTextColorDefault = Color(0xff333333);
  double leftIconSpaceDefault = 10;
  double rightTextSizeDefault = 14;
  Color rightTextColorDefault = Color(0xff333333);
  double rightIconSpaceDefault = 10;
  double paddingVerticalDefault = 16.0;
  double paddingHorizontalDefault = 10.0;
  Color backgroupColorDefault = Colors.white;
  bool showDividerDefault = false;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      child: Container(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              width: double.infinity,
              decoration: BoxDecoration(
                  color: backgroupColor ?? backgroupColorDefault,
                  borderRadius: BorderRadius.circular(radio ?? 0)),
              padding: EdgeInsets.symmetric(
                  vertical: paddingVertical ?? paddingVerticalDefault,
                  horizontal: paddingHorizontal ?? paddingHorizontalDefault),
              child: Flex(
                  direction: Axis.horizontal,
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        leftIcon ??
                            SizedBox(
                              width: 0,
                            ),
                        SizedBox(
                          width: leftIconSpace ?? leftIconSpaceDefault,
                        ),
                        Text(
                          leftText ?? "",
                          style: TextStyle(
                              fontSize: leftTextSize ?? leftTextSizeDefault,
                              color: leftTextColor ?? leftTextColorDefault,
                              fontWeight: (leftTextBold ?? false) ? FontWeight.bold:FontWeight.normal),
                        )
                      ],
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: [
                        Text(
                          rightText ?? "",
                          style: TextStyle(
                              fontWeight:  (rightTextBold ?? false) ? FontWeight.bold:FontWeight.normal,
                              fontSize: rightTextSize ?? rightTextSizeDefault,
                              color: rightTextColor ?? rightTextColorDefault),
                        ),
                        SizedBox(
                          width: rightIconSpace ?? rightIconSpaceDefault,
                        ),
                        rightIcon ?? SizedBox(),
                      ],
                    )
                  ]),
            ),
            showDivider ?? showDividerDefault
                ? Divider(
                    height: 1,
                    color: Color(0xffededed),
                  )
                : SizedBox()
          ],
        ),
      ),
    );
  }
}
